import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response } from 'express';

@Injectable()
export class LoggerMiddleware implements NestMiddleware {
  use(req: Request, res: Response, next: () => void) {
    const { method } = req
    if (method === 'GET') {
      console.log("请求接口地址:", req.baseUrl, `参数:${req.query}`, req.method)
    } else {
      console.log("请求接口地址:", req.baseUrl, req.method, req.body,)
    }
    next();
  }
}